package com.yx.ehis.system;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import com.yx.system.SystemContext;
import com.yx.system.model.Context;

public class Activator extends AbstractUIPlugin {
	public static final String PLUGIN_ID = "e-his-client";
	private static Activator plugin;

	public Activator() {
	}

	@Override
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;
		// 取版本号
		Context.getInstance().setVersion(
				context.getBundle().getHeaders().get("Bundle-Version"));
		Context.getInstance().setPlugin_id(PLUGIN_ID);
		Context.getInstance().setProductName(
				context.getBundle().getHeaders().get("Bundle-Name"));
		// TODO 测试集成
		System.out.println(SystemContext.getInstance().getResourceBean(
				"sessionFactory"));
	}

	@Override
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
	}

	public static Activator getDefault() {
		return plugin;
	}

	public static ImageDescriptor getImageDescriptor(String path) {
		return imageDescriptorFromPlugin(PLUGIN_ID, path);
	}
}
